#version 430 core

layout(local_size_x=256) in;

layout(binding=0) coherent buffer sparseMatrixBuffer
{
	float sparseMatrix[];
};

layout(binding=1) coherent buffer inVectorBuffer
{
	float inVector[];
};

layout(binding=2) coherent buffer outVectorBuffer
{
	float outVector[];
};

uniform uint numRows;

void main(void)
{
	uint rowID = gl_GlobalInvocationID.x;
	if (rowID < numRows)
	{
		float diag = sparseMatrix[rowID * 9];
		outVector[rowID] = mix(inVector[rowID] / diag, 0.0f, abs(diag)<0.0001);
	}
}